package leetcode

//https://leetcode.com/problems/reverse-linked-list/


fun main(args: Array<String>) {

}

fun reverseList(head: ListNode?): ListNode? {
    if (head == null) return null
    var curr: ListNode? = head
    var prev: ListNode? = null
    var next: ListNode? = curr?.next
    while (curr != null) {
        curr.next = prev
        prev = curr
        curr = next
        next = curr?.next
    }
    return prev
}
